
#ifndef __TERMINAL_H__
#define __TERMINAL_H__

#include <betty/terminal.h>
#include "parser.h"
#include "screen.h"
#include "utf8.h"



struct Betty_Modes {
	/* ANSI modes */
	int LNM;	/* linefeed/new line mode */
	int IRM;	/* insertion replacemet mode */

	/* DEC private modes */
	int DECCOLM;	/* DEC column mode */
	int DECOM;	/* DEC origin mode */	
	int DECAWM;	/* DEC auto wrap mode */
	int DECKPAM;	/* DEC keypad application mode */
	int DECCKM;	/* DEC cursor key mode */
};


struct Betty_Terminal {
	struct UTF8	utf8;
        struct Parser   parser;

        /* The both screens. 
         * SCREEN_NORMAL is the default screen and has a scroll back
         * buffer. The SCREEN_ALTERNATE is the alternate screen without
         * scroll back buffer
         */
        struct Screen   screen_normal;
        struct Screen   screen_alternate;
        struct Screen   *screen;	/* pointer to current screen */

	/* flags */
	int		wrap;
	char		*tabstop;	/* tabstop flag for each column */

	/* scrolling range */
	int 		scroll_top;
	int 		scroll_bottom;

	/* current mode settings */
	struct Betty_Modes modes;

	/* current attribute */
	struct Betty_CellAttribute attr;

	/* Saved parameters for DECSC/DECRC */
	struct {
		int				valid;
		int				wrap;
		int 				DECOM;
		struct Betty_Position		cursor;
		struct Betty_CellAttribute	attr;
	} saved;

        /* Transmitter */ 
	void			*xmit;
	Betty_TransmitFunction	xmit_func;
};



#endif



